package com.codingfuture.glacioralarm.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.codingfuture.glaciercommon.util.PageDate;
import com.codingfuture.glaciercommon.util.PageParam;
import com.codingfuture.glaciercommon.util.Result;
import com.codingfuture.glacioralarm.dto.MeterAndWareHouseDTO;
import com.codingfuture.glacioralarm.service.AlarmConfigurationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author :zxw
 * @date 2025-04-14 09:54
 * @description:
 */
@RestController
@Slf4j
public class AlarmConfiguration {
    @Autowired
    private AlarmConfigurationService alarmConfigurationService;
    @GetMapping("/alarmConfiguration/selectByPage")
    public Result<PageDate<List<MeterAndWareHouseDTO>>> selectByPage(String name, PageParam pageParam){
        Page<MeterAndWareHouseDTO> page = new Page<>(pageParam.getPageNum(), pageParam.getPageSize());
        alarmConfigurationService.selectByPage(name,page);
        PageDate<List<MeterAndWareHouseDTO>> pageDate = new PageDate<>();
        pageDate.setRows(page.getRecords());
        pageDate.setTotal(page.getTotal());
        log.debug("selectByPage{}",pageParam);
        return Result.successes(pageDate);
    }

}
